﻿using System;

namespace LeanApp.Bll
{
    /// <summary>
    /// 学习经验曲线业务
    /// </summary>
    public class LearnBll
    {
        /// <summary>
        /// 获取第n次执行的值
        /// </summary>
        /// <param name="n">次数</param>
        /// <param name="t1">首次值</param>
        /// <param name="experience">改善经验</param>
        /// <returns>n次值</returns>
        public double GetNVal(int n, double t1, double experience)
        {
            double val1 = Math.Log10(experience) / Math.Log10(2);
            double val2 = Math.Pow(n, val1);
            return t1 * val2;
        }

        /// <summary>
        /// 获取目标结果的次数
        /// </summary>
        /// <param name="t1">首次值</param>
        /// <param name="target">目标值</param>
        /// <param name="experience">改善经验</param>
        /// <returns>次数</returns>
        public int GetN(double t1, double target, double experience)
        {
            double val1 = target / t1;
            double val2 = Math.Log10(experience) / Math.Log10(2);
            double val3 = 1.0 / val2;
            return Convert.ToInt32(Math.Round(Math.Pow(val1, val3), 0));
        }
    }
}
